<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php session_start();
$Emails=$_POST['pusername'];
$link = mysql_connect('cash2uca.ipagemysql.com', 'cash2uca', 'actW3740!@#$'); 
if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
mysql_select_db(cash2uca);
$sql = "SELECT UserName , UserPWD FROM MainTable WHERE UserName= '$_POST[pusername]'";
$sqlresult=mysql_query($sql);
$row = mysql_fetch_array($sqlresult);
$_SESSION['username']=$row['UserName'];
$_SESSION['usrpwd']=$row['UserPWD'];


if($_SESSION['username']!=$_POST['pusername']||$_SESSION['usrpwd']!=md5($_POST['oldpwd']))
{echo "Sorry, your username and old password are not matched in our system";
exit();
}

$sqlinsert="UPDATE MainTable SET UserPWD=md5('$_POST[newpwd]') WHERE UserName='".$_SESSION['username']."'";

$resultin=mysql_query($sqlinsert);

//email validation function
function spamcheck($field)
  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }

//To send out email if session email is set up already
if (isset($_POST['pusername']))
  {//if "email" is filled out, proceed

  //check if the email address is invalid
  $mailcheck = spamcheck($_POST['pusername']);
  if ($mailcheck==FALSE)
    {
    echo "Invalid email address, please re-enter your username";
	include "CPASSWORD.php";
	exit();
    }
  else
    {//send email
    $email = $_POST['pusername'];
    $subject = "Please remember your new password";
    $message = "Hi, \n\n Your username is ".$email. " and your new password is '$_POST[newpwd]'. Please remember to use your new password to login when you come back. \n\nThank you for choosing www.cash2u.ca!\n\nCash2u.ca appreciates your business!\n\n";
    $message=wordwrap($message,70);

    mail($email, $subject,$message,"From:customerservicessupport@cash2u.ca");
    }
  }
//The above is to send out email to the applicant
$link = mysql_connect('cash2uca.ipagemysql.com', 'cash2uca', 'actW3740!@#$'); 
?>

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cash2u.ca: Payday loan online application processing</title>
<META NAME="Keywords" CONTENT="payday loan, payday cash advance, online, payday advance, payday cash loan, payday loans, cash advance, paycheque loans, short term,
	money mart, money here, quick cash,check,cashing,easy,tax, bill,payment,currency,card,credit,Easy Cash Advances, Internet Payday loans, Payroll Advance, Payday Loan Services,
	Online Payday Advances, Online Payday Loan Provider, Pay Day, Canada">
<META NAME="Description" CONTENT=Cash2u.ca offers online payday loans and cash advance for Canadians">

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
<script src="./css/jquery.maskedinput.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="./css/main_style.css"/>
<link rel="stylesheet" type="text/css" href="./css/index.css"/>
</head>
<body onload="DoMath()">
<div id="maincontainer">

<div id="headsection">
<div id="headback">
<br/><br/><br/><h1><a style="color:white;" href="apply.php">Cash to you</a></h1><p id="headpara"><a style="color:white;" href="apply.php">Simple Easy Fast - Your payday loan</a></p>
</div>
</div>

<table cellspacing="4" cellpadding="1" border="0" style="margin:5px;height:50px;width:740px;background-color:#084c8d;border:1px solid #e5e5e5;color:white;font-size:110%;font-weight:bold;">
<tr><td width="20"></td>
<td width="90" align="center"><a class="headlink" href="index.html">HOME</a></td>
<td width="90" align="center"><a class="headlink" href="apply.php">APPLY</a></td>
<td width="130" align="center"><a class="headlink" href="member.php"><span class="displace">MEMBERS</span></a></td>
<td width="110" align="center"><a class="headlink" href="career.php"><span class="displace">CAREER</span></a></td>
<td width="90" align="center"><a class="headlink" href="faqs.php"><span class="displace">FAQ's</span></a></td>
<td width="90" align="center"><a class="headlink" href="contact.php"><span class="displace">CONTACT</span></a></td>
<td width="140"></td>
</tr>
</table>

<div id="content">

    	<form name="application" method="post" action="">
	<table>	
	<tr>
	<td width="740" align="left">Hi,</br></br>

Your new password has been changed and sent to your provided email address successfully. Please check your email address to get your new password and use it to login when you come back.</br></br>

Thank you for choosing <a href="www.cash2u.ca">www.cash2u.ca!</a></br></br>

Cash2u.ca appreciates your business.</br></br>

5 seconds later, this page will be redirected to: <a href="www.cash2u.ca">www.cash2u.ca</a>

		</td>
		</tr>

	</table>

	</form>

<div id="footer">
<div id="imlinks"><b><strong>Copyright &#169 2011 Cash2u.ca All rights reserved</strong></b></div>
</div>

</div>

<?php
header("refresh:5;url=http://www.cash2u.ca");
session_destroy();
?> 
</body>
</html>